package com.zy.mybatis.controller;

import com.zy.mybatis.entity.Book;
import com.zy.mybatis.service.BookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/book")
public class BookController {

    @Autowired
    BookService bookService;

    @PostMapping("findBooks")
    public ResponseEntity findBooks(){
      List<Book> books =  bookService.findBooks();
      return new ResponseEntity(books, HttpStatus.OK);
    }

}
